What are the oldest known writings that state that Mary was without sin?
The earliest Christian writings outside the bible are from what are called the Church Fathers, from around the middle of the second century onwards for a few hundred years.
On the Immaculate Conception explicitly, the earliest would appear to be Hippolytus and Origen:
He [Jesus] was the ark formed of incorruptible wood. For by this is signified that His tabernacle [Mary] was exempt from defilement and corruption (Hippolytus, Orat. In Illud, Dominus pascit me, in Gallandi, Bibl. Patrum, II, 496 ante [A.D. 235]).
This Virgin Mother of the Only-begotten of God is called Mary, worthy of God, immaculate of the immaculate, one of the one (Origen, Homily 1 [A.D. 244]).
Earlier writers hint at the doctrine, by comparing Mary to Eve, who was created without the stain of sin:
[Jesus] became man by the Virgin so that the course that was taken by disobedience in the beginning through the agency of the serpent might be also the very course by which it would be put down. Eve, a virgin and undefiled, conceived the word of the serpent and bore disobedience and death. But the Virgin Mary received faith and joy when the angel Gabriel announced to her the glad tidings that the Spirit of the Lord would come upon her and the power of the Most High would overshadow her, for which reason the Holy One being born of her is the Son of God. And she replied, "Be it done unto me according to your word" (Luke 1:38) (Justin Martyr, Dialogue with Trypho 100 [A.D. 155]).
Consequently, then, Mary the Virgin is found to be obedient, saying, "Behold, O Lord, your handmaid; be it done to me according to your word." Eve . . . who was then still a virgin although she had Adam for a husband — for in paradise they were both naked but were not ashamed; for, having been created only a short time, they had no understanding of the procreation of children . . . having become disobedient [sin], was made the cause of death for herself and for the whole human race; so also Mary, betrothed to a man but nevertheless still a virgin, being obedient [no sin], was made the cause of salvation for herself and for the whole human race. . . . Thus, the knot of Eve's disobedience was loosed by the obedience of Mary. What the virgin Eve had bound in unbelief, the Virgin Mary loosed through faith (Iranaeus, Against Heresies 3:22:24 [A.D. 189]).
There are further, later comments where I found those but those are the earliest cited. These four are the earliest of the Fathers.
It is important to note that before the "Edict of Milan" the church was a persecuted Church and the Gospel as well as the traditions passed on by the apostles were spread orally and in many distant geographical areas.
After the Edict, Christians under the protection and support of the Emperor Constantine where able to freely practice and articulate those truths that were preserved.
The Church now freed from persecution would as they should, define, by the bishops and presbyters, firstly those things concerning Christ. Which they did in the formulation of the Creed. The kingdom of God (the Church) now free to blossom into the biggest of trees, had many more things to address. Arianism, gnostism, montanism, Sabellianism, the early teachings of some that concerned the Lord himself, primacy of concern.
When the Church, after addressing the heretical teachings in the early times, now could address other concerns.
We have the writings of Saint Ambrose:
"Mary, a virgin not only undefiled but a virgin whom grace has made inviolate, free from every stain." - St. Ambrose of Milan, 340-370 AD.
"Every personal sin must be excluded from the Blessed Virgin Mary for the sake of the honor of God." - St. Augustine, 390 AD.
"You, and your Mother are alone in this. You are wholly beautiful in every respect. There is in you, Lord, no stain, nor any spot in your Mother." - St. Ephraem, 350 AD.
We have the first century cave pictures of Mary at Saint Agnes, depicting Mary as very present and having even then her unique roll as intersesser.
Then of course there is the
"Sub tuum praesidium"
Greek Text 250 AD.
Ὑπὸ τὴν σὴν εὐσπλαγχνίαν, καταφεύγομεν, Θεοτόκε. Τὰς ἡμῶν ἱκεσίας, μὴ παρίδῃς ἐν περιστάσει, ἀλλ᾽ ἐκ κινδύνων λύτρωσαι ἡμᾶς, μόνη Ἁγνή, μόνη εὐλογημένη.
Beneath your compassion, We take refuge, O Mother of God: do not despise our petitions in time of trouble: but rescue us from dangers, only pure, only blessed one.
These doctrines preserved in tradition by the bishops and the faithful were past down most likely from its origins in the Large city of Ephesis where the Evangelist John preached and with him under his care by the instruction of God, The Virgin Mary spent many days preaching and reciting all those things that were not written but understood organically in oral tradition.
"Blessed rather are those who hear the word of God and obey it."
A correction the Lord gave to the crowd when a woman suggested that she was blessed for baring Jesus and breast feeding him. The correction was not to rebuke the woman and have Christ take away the very honor that the stranger gives to The Mother of God, but to instruct her as to why She and anyone else would be considered blessed. To hear the word of God and obey it as Mary did with her consent to be "The Women" of Prophecy.
Christ heard the will of God the Faher and obeyed it, despite the human desires of the flesh, in the same way, Mary too hears the will of the lord and obeys.
Conceived without sin, saved by Christ prior to birth from any and all sin, She continues even now to do the will of God.
And the angel being come in, said unto her: Hail, full of grace [κεχαριτωμένη], the Lord is with thee: blessed art thou among women.
To be full of grace to such an extent as to conceive the 2nd Person of the Holy Trinity is incompatible with sinning.
Hail, full of grace:  by the greatest share of divine graces granted to any creature. This translation, approved by the ancient Fathers, agrees with the ancient Syriac and Arabic versions. There was no need therefore to change it into gracious, with Erasmus; into freely beloved, with Beza; into highly favoured, with the Prot. translators. For if seven deacons (Acts vi. 3.) are said to be full of the Holy Ghost, as it is again said of S. Stephen, (Acts vii. 55.) and also of the same S. Stephen, (Acts vi. v. 8.) that he was full of grace, (as the learned Dr. Wells translates it in his amendments made to the Prot. translation) why should any one be offended at this salutation given to the blessed mother of God; who would not have been raised to this highest dignity, had not her s\oul been first prepared for it by the greatest share of divine graces? — The Lord is with thee, by his interior graces; and now, at this moment, is about to confer upon thee the highest of all dignities, by making thee truly the mother of God. Wi. — The Catholic Church makes frequent use of these words which were brought by the archangel from heaven, as well to honour Jesus Christ and his virgin Mother, as because they were the first glad tidings of Christ's incarnation, and man's salvation; and are the very abridgment and sum of the whole gospel. In the Greek Church, they are used daily in the Mass. See the Liturgy of S. James, and that of S. Chrysos.
Pope Pius IX gives in his dogmatic definition on the Immaculate Conception, Ineffabilis Deus (1854), many reasons for Mary's sinlessness. Here's what he says about Luke 1:28 and Luke 1:42:
When the Fathers and writers of the Church meditated on the fact that the most Blessed Virgin was, in the name and by order of God himself, proclaimed full of grace [Cf. Lk 1:28.] by the Angel Gabriel when he announced her most sublime dignity of Mother of God, they thought that this singular and solemn salutation, never heard before, showed that the Mother of God is the seat of all divine graces and is adorned with all gifts of the Holy Spirit. To them Mary is an almost infinite treasury, an inexhaustible abyss of these gifts, to such an extent that she was never subject to the curse and was, together with her Son, the only partaker of perpetual benediction. Hence she was worthy to hear Elizabeth, inspired by the Holy Spirit, exclaim: "Blessed are you among women, and blessed is the fruit of your womb." [Ibid., 42. ]
He also says:
As if these splendid eulogies and tributes were not sufficient, the Fathers proclaimed with particular and definite statements that when one treats of sin, the holy Virgin Mary is not even to be mentioned; for to her more grace was given than was necessary to conquer sin completely. [Cf. St. Augustine: De Natura et Gratia, c. 36. ] They also declared that the most glorious Virgin was Reparatrix of the first parents, the giver of life to posterity; that she was chosen before the ages, prepared for himself by the Most High, foretold by God when he said to the serpent, "I will put enmities between you and the woman." [Gn 3:15]—unmistakable evidence that she was crushed the poisonous head of the serpent. And hence they affirmed that the Blessed Virgin was, through grace, entirely free from every stain of sin, and from all corruption of body, soul and mind; that she was always united with God and joined to him by an eternal covenant; that she was never in darkness but always in light; and that, therefore, she was entirely a fit habitation for Christ, not because of the state of her body, but because of her original grace.
The doctrine of a sinless Mary so-called or her immaculate conception was not officially defined until 1854 by the Roman Catholic Church. Prior to that, there were thoughts and arguments on both sides about Mary's state as a human being.
Also to be clear, Hippolytus is not saying Mary was the ark, but rather Jesus is the ark of incorruptible seed.
And an ark of imperishable wood was the Saviour Himself. For by this was signified the imperishable and incorruptible tabernacle (of His body), which engendered no corruption of sin. For the man who has sinned also has this confession to make: “My wounds stank, and were corrupt, because of my foolishness.” But the Lord was without sin, being of imperishable wood in respect of His humanity,—that is to say, being of the Virgin and the Holy Spirit, covered, as it were, within and without with the purest gold of the Word of God https://ccel.org/ccel/hippolytus/fragments/anf05.iii.iv.ii.vii.vi.html
This paragraph is quoted later by Theordoret circa 450 as shown next. Christ is the sinless or incorruptible ark in which we take refuge.
Testimony of the Holy Hippolytus, Bishop and Martyr, from his discourse on1123“The Lord is my shepherd”:— “And an ark of incorruptible wood was the Saviour Himself, for the incorruptibility and indestructibility of His Tabernacle signified its producing no corruption of sin. For the sinner who confesses his sin says ‘My wounds stink and are corrupt because of my foolishness.’1124 But the Lord was without sin, made in His human nature of incorruptible wood, that is to say, of the Virgin and the Holy Ghost, overlaid within and without, as it were, by purest gold of the word of God.” https://ccel.org/ccel/schaff/npnf203/npnf203.iv.ix.ii.html
Basically, the earliest reference may be from Origen.
How old is the doctrine of a sinless Mary? Nothing before the 2nd century AD on it. It was never known by the bible writers, otherwise they would have put it in the scriptures as those confused church fathers did in their writings in the 2nd century. I often find it ironic that the supposed successors of St. Peter's chair all claim that Mary is sinless while the supposed first Pope never even mentions her name in his Epistles. Hmmmmm.